import { ref, onMounted } from "vue";
import axios from "axios";
//获取一张狗的图片:保存的数据
const dogUrl = ref("");
const loading = ref(true);
//获取一张狗的图片:发送请求
const getDogUrl = async () => {
  console.log(1);

  const result = await axios.get("https://dog.ceo/api/breeds/image/random");

  loading.value = false;
  dogUrl.value = result.data.message;
};

//获取一张狗的图片:生命周期函数
onMounted(() => {
  getDogUrl();
});

export default {
  dogUrl,
  loading,
};
